]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
st-icon: Don't cause a redraw by replacing the icon with itself
authorAdel Gadllah <adel.gadllah@gmail.com>
Sat, 2 Mar 2013 20:50:47 +0000 (21:50 +0100)
committerAdel Gadllah <adel.gadllah@gmail.com>
Mon, 4 Mar 2013 23:03:29 +0000 (00:03 +0100)
Check if the two icons match before setting a new icon, if they
do don't do anything.

Based on patch from Owen Taylor <otaylor@fishsoup.net>

https://bugzilla.gnome.org/show_bug.cgi?id=694988

src/st/st-icon.c

index d608672645bb129ea145e5feaac35075240601a3..4d149e1c12c3888aad2aeea270bc547c64672fbf 100644 (file)
@@ -534,23 +534,32 @@ void
 st_icon_set_icon_name (StIcon      *icon,
                        const gchar *icon_name)
 {
-  StIconPrivate *priv;
+  StIconPrivate *priv = icon->priv;
+  GIcon *gicon = NULL;
 
   g_return_if_fail (ST_IS_ICON (icon));
 
-  priv = icon->priv;
+  if (icon_name)
+    gicon = g_themed_icon_new_with_default_fallbacks (icon_name);
+
+  if (g_icon_equal (priv->gicon, gicon)) /* do nothing */
+    {
+      g_object_unref (gicon);
+      return;
+    }
 
   if (priv->gicon)
     g_object_unref (priv->gicon);
 
-  if (icon_name)
-    priv->gicon = g_themed_icon_new_with_default_fallbacks (icon_name);
-  else
-    priv->gicon = NULL;
+  g_object_freeze_notify (G_OBJECT (icon));
+
+  priv->gicon = gicon;
 
   g_object_notify (G_OBJECT (icon), "gicon");
   g_object_notify (G_OBJECT (icon), "icon-name");
 
+  g_object_thaw_notify (G_OBJECT (icon));
+
   st_icon_update (icon);
 }
 
@@ -579,7 +588,7 @@ st_icon_set_gicon (StIcon *icon, GIcon *gicon)
   g_return_if_fail (ST_IS_ICON (icon));
   g_return_if_fail (gicon == NULL || G_IS_ICON (gicon));
 
-  if (icon->priv->gicon == gicon) /* do nothing */
+  if (g_icon_equal (icon->priv->gicon, gicon)) /* do nothing */
     return;
 
   if (icon->priv->gicon)